package cafeshop;

import java.util.*;

//public
public class CafeShop {
    String name = "";
    
    Random random = new Random();

    Integer income = 0;
    Integer shopAverage = 0;
    
    HashMap<String, Integer> rating = new HashMap<String, Integer>();

    public void initialisedRating() {
        int rand = random.nextInt(5) + 1;
        int sum = 0;
        int count = 3;

        sum += rand;
        rating.put("Americano", rand);
        rand = random.nextInt(5) + 1;
        
        sum += rand;
        rating.put("Latte", rand);
        rand = random.nextInt(5) + 1;
        
        sum += rand;
        rating.put("Mocha", rand);
        
        this.shopAverage = sum / count;
    }

    public static void getHistoryRating() {
        // CafeShop shop = new CafeShop();
        List<CafeShop> shopList = new ArrayList<CafeShop>();

        for (int i = 0; i < 101; i++) {
            CafeShop toBeAdded = new CafeShop();
            toBeAdded.name = "shop" + i;
            toBeAdded.initialisedRating();
            shopList.add(toBeAdded);
            System.out.println(toBeAdded.name + " " + toBeAdded.shopAverage);
        }

        /*
           Iterator example
         * shop.initialisedRating(); Iterator it = shop.rating.entrySet().iterator();
         * while(it.hasNext()){ Map.Entry pair = (Map.Entry)it.next();
         * System.out.println(pair.getKey() + " = " + pair.getValue()); it.remove(); }
         */
    }

}
